import table2excel from 'js-table2excel'
import { cloneDeep } from 'lodash'

export default function tableToExcel({
  columnImgs = [],
  columns,
  data,
  title = 'excel'
}) {
  let temp = cloneDeep(columns)
    .filter((item) => !['', '操作'].includes(item.title))
    .map((item) => ({
      ...item,
      key: item.field,
      type: columnImgs.includes(item.field) ? 'image' : 'text'
    }))
  table2excel(temp, data, title)
}
